package com.jixiantubu.adapter;

import image.SmartImageView;

import java.util.List;
import com.example.jixiantubu.R;
import com.jixiantubu.bean.UserBean;
import com.jixiantubu.util.MyApplication;
import com.lidroid.xutils.BitmapUtils;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class GuanzhuAdapter extends BaseAdapter {
	Context context;
	List<UserBean> list;
	LayoutInflater mInflater;
	ViewHolder mhHolder;
	BitmapUtils bitmapUtils;
	
	public GuanzhuAdapter(Context context, List<UserBean> list) {
		super();
		this.context = context;
		this.list = list;
		mInflater=LayoutInflater.from(context);
		bitmapUtils=new BitmapUtils(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	class ViewHolder{
		SmartImageView imageView;
		TextView textView;
	}
	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		if(arg1==null){
			arg1=mInflater.inflate(R.layout.wo_guanzhu_item, null);
			mhHolder=new ViewHolder();
			mhHolder.imageView=(SmartImageView) arg1.findViewById(R.id.wo_guanzhuitem_imageView);
			mhHolder.textView=(TextView) arg1.findViewById(R.id.wo_guanzhuitem_textView);
			arg1.setTag(mhHolder);
		}else {
			mhHolder=(ViewHolder) arg1.getTag();
		}
		//动态设置每一行的值:图片和文本
		//mhHolder.textView.setText(list.get(arg0).)
		mhHolder.textView.setText(list.get(arg0).getUser_nickname());
			String url="http://" + MyApplication.getIP()
			+ ":8080/Jinnang/img/"+list.get(arg0).getUser_imgPath();
		Log.e("imagepath", url);
		mhHolder.imageView.setstyle("circle");
		mhHolder.imageView.setImageUrl(url);
		
//		MyApplication.bitmapUtils.display(mhHolder.imageView, "http://bbs.lidroid.com/static/image/common/logo.png");
		return arg1;
	}
                                                                                                                    
}
